﻿<%@ Page Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" 
	CodeFile="TaskInfo.aspx.cs" 
	Inherits="TaskInfo" Title="Просмотр информации по задаче" %>

<%@ Import Namespace="Progresoft.Common" %>
<%@ Import Namespace="Progresoft.Scheduler.RemoteInterface.Api" %>
<%@ Import Namespace="Progresoft.Scheduler.RemoteInterface" %>
<%@ Import Namespace="Progresoft.Scheduler.RemoteInterface.DataAccess" %>

<asp:Content ID="Content2" ContentPlaceHolderID="cphMain" runat="server">

<div class="descriptonTask">
	<h2><asp:Literal ID="litTaskName" runat="server" /></h2>
</div>
<br />
<table cellspacing="0" cellpadding="0">
	<tr>
		<td valign="top">
			<div class="schedulerTable">
				<h3>Параметры задачи</h3>
				<p><strong>Класс:</strong> <asp:Literal ID="litClassName" runat="server" /></p>
				<p><strong>Сборка:</strong> <asp:Literal ID="litAssembly" runat="server" /></p>
				<p><strong>Ключ:</strong> <asp:Literal ID="litKey" runat="server" /></p>
				<p><strong>Описание:</strong> <asp:Literal ID="litDescription" runat="server" /></p>
			</div>
		</td>
		<td valign="top">
			<div class="schedulerTable">
				<h3>Расписание запусков</h3>
				<p><asp:HyperLink ID="lnkNewSchedule" runat="server" Text="Добавить новое расписание" /></p>
				<asp:ListView ID="listSchedules" runat="server" 
					ItemPlaceholderID="ItemPlaceHolder"
					onitemcommand="listSchedules_ItemCommand">
					<LayoutTemplate>
						<table cellpadding="0" cellspacing="2">
								<col style="width:auto;" />
								<col style="width:auto" align="center" />
								<col style="width:40px;" align="center" />
								<col style="width:40px;" align="center" />
								<tr>
									<th>Время запуска</th>
									<th>Наименование</th>
									<th></th>
									<th></th>
								</tr>
								<tr id="ItemPlaceHolder" runat="server"></tr>
							</table>
					</LayoutTemplate>
					<ItemTemplate>
						<tr>
							<td>&nbsp;<%# GetExecuteTime((TaskSchedule)Container.DataItem) %></td>
							<td>&nbsp;<%# Eval("Name")%></td>
							<td>
								<asp:HyperLink ID="lnkLog" runat="server" ImageUrl="~/Images/scheduler/edit.gif" 
											ToolTip="Редактировать расписание"
											NavigateUrl='<%# string.Format("~/EditSchedule.aspx?system={1}&task={2}&schedule={0}", Eval("ID"), SystemName, TaskKey) %>' />
							</td>
							<td>
								<asp:ImageButton ID="lnkDel" runat="server" ImageUrl="~/Images/scheduler/del.gif" 
											ToolTip="Удалить расписание"
											CommandArgument='<%# Eval("ID") %>'
											CommandName="DeleteSchedule"
											OnClientClick="javascript:return confirm('Вы уверены, что хотите удалить расписание')"
											/>
							</td>
						</tr>
					</ItemTemplate>
				</asp:ListView>
			</div>
		</td>
	</tr>
</table>
	
<div class="schedulerTable">
	<h3>Запуски задачи</h3>
	<p>
		Страницы: 
		<strong>
			<asp:DataPager ID="pageSelector" runat="server" PagedControlID="listEvents" PageSize="10">
				<Fields>
					<asp:NumericPagerField ButtonCount="7" 
						NextPageText=">>" 
						PreviousPageText="<<" />
				</Fields>
			</asp:DataPager>
		</strong>
	</p>
	
	<asp:ListView ID="listEvents" runat="server" 
		DataSourceID="dsEvents"
		ItemPlaceholderID="ItemPlaceHolder">
		<LayoutTemplate>
			<table cellpadding="0" cellspacing="2">
				<col style="width:60px;" align="center" />
				<col style="width:20%;"  align="center"/>
				<col style="width:20%;"  align="center"/>
				<col style="width:auto;" align="center" />
				<col style="width:60px;" align="center" />
				<tr>
					<th>Статус</th>
					<th>Время запуска</th>
					<th>Время завершения</th>
					<th>Инициатор запуска</th>
					<th>Лог</th>
				</tr>
				<tr id="ItemPlaceHolder" runat="server"></tr>
			</table>
		</LayoutTemplate>
		<ItemTemplate>
			<tr class="<%# GetRowCss(((ScheduledTaskEvent)Container.DataItem).Status) %>">
				<td>
					<asp:Image ID="imgStatus" runat="server" 
						ImageUrl="<%# GetScheduledTaskStatusIcon(((ScheduledTaskEvent)Container.DataItem).Status) %>"
						ToolTip="<%# EnumHelper.GetValueName<TaskEventState>(((ScheduledTaskEvent)Container.DataItem).Status) %>" />
				</td>
				<td>&nbsp;<%# Eval("StartedAt")%></td>
				<td>&nbsp;<%# Eval("FinishedAt")%></td>
				<td>
					<asp:Label runat="server" 
						Text='<%# Eval("Initiator", " &nbsp;{0}") %>' 
						Font-Bold='<%# (bool)Eval("IsManual") %>' /> </td>
				<td>
					&nbsp;<asp:HyperLink ID="lnkLog" runat="server" ImageUrl="~/Images/scheduler/view_log.gif" 
								ToolTip="Посмотреть лог"
								Visible="<%#((ScheduledTaskEvent)Container.DataItem).LogID.HasValue %>" 
								NavigateUrl='<%# string.Format("~/ViewLog.aspx?type=scheduled&log={0}&system={1}", Eval("LogID"), Eval("ClientSystem")) %>' />
		
				</td>
			</tr>
		</ItemTemplate>
	</asp:ListView>
	
	<asp:ObjectDataSource ID="dsEvents" runat="server"
		TypeName="TaskEventSearcher"
		MaximumRowsParameterName="pageSize" StartRowIndexParameterName="startIndex"
		SelectMethod="ListScheduledTaskEvents"  
		SelectCountMethod="ListScheduledTaskEventsCount"
		EnablePaging="true"
		OnObjectDisposing="ds_ObjectDisposing"
		>
			<SelectParameters>
				<asp:QueryStringParameter Name="systemName" QueryStringField="system" />
				<asp:QueryStringParameter Name="taskKey" QueryStringField="task" />
			</SelectParameters>
		</asp:ObjectDataSource>
</div>
<br />
<br />
<br />
<br />
</asp:Content>

